package jltx.fragmentpageframework.simple.fragment.pager;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import cn.jltx.utils.ViewHelper;
import cn.jltx.utils.XqLog;
import jltx.fragmentpageframework.R;
import jltx.fragmentpageframework.simple.fragment.base.BaseFragment;

/**
 * @author jltxseo
 *         Created by junlintianxia on 2017/05/22.
 */

public class NewsChildFragment extends BaseFragment{
    private static final String ARG_POS = "arg_pos";
    private static final String ARG_TITLE = "arg_title";
    private int childPos;
    private String childTitle;

    private TextView textView;
    public static NewsChildFragment newInstance(int pos,String childTitle){
        Bundle args = new Bundle();
        args.putInt(ARG_POS,pos);
        args.putString(ARG_TITLE,childTitle);

        NewsChildFragment fragment = new NewsChildFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle args = getArguments();
        if(args != null){
            childPos = args.getInt(ARG_POS);
            childTitle = args.getString(ARG_TITLE);
        }
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_simple_new_tab_child,container,false);
        textView = ViewHelper.findViewById(rootView,R.id.tv_new_tab_child);

        return rootView;
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        XqLog.d(TAG,"setUserVisibleHint.isVisibleToUser:"+isVisibleToUser+this.getClass().getName()+",childTitle:"+childTitle+",pos:"+childPos);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        textView.setText(childTitle);
    }
}
